//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.ctrip.corp.obt.shard.constants;

import com.ctrip.corp.obt.generic.utils.StringUtils;

public enum DbType {
    MYSQL(1,"mysql", "MySql数据库", "cn.astana.sharding.extension.plugins.pagination.dialects.MySqlDialect"),
    MARIADB(2, "mariadb", "MariaDB数据库", "cn.astana.sharding.extension.plugins.pagination.dialects.MariaDBDialect"),
    ORACLE(3, "oracle", "Oracle11g及以下数据库(高版本推荐使用ORACLE_NEW)", "cn.astana.sharding.extension.plugins.pagination.dialects.OracleDialect"),
    ORACLE_12C(4, "oracle12c", "Oracle12c+数据库", "cn.astana.sharding.extension.plugins.pagination.dialects.Oracle12cDialect"),
    DB2(5, "db2", "DB2数据库", "cn.astana.sharding.extension.plugins.pagination.dialects.DB2Dialect"),
    H2(6, "h2", "H2数据库", "cn.astana.sharding.extension.plugins.pagination.dialects.H2Dialect"),
    HSQL(7, "hsql", "HSQL数据库", "cn.astana.sharding.extension.plugins.pagination.dialects.HSQLDialect"),
    SQLITE(8, "sqlite", "SQLite数据库", "cn.astana.sharding.extension.plugins.pagination.dialects.SQLiteDialect"),
    POSTGRE_SQL(9, "postgresql", "Postgre数据库", "cn.astana.sharding.extension.plugins.pagination.dialects.PostgreDialect"),
    SQL_SERVER2005(10, "sqlserver2005", "SQLServer2005数据库", "cn.astana.sharding.extension.plugins.pagination.dialects.SQLServer2005Dialect"),
    SQL_SERVER(11, "sqlserver", "SQLServer数据库", "cn.astana.sharding.extension.plugins.pagination.dialects.SQLServerDialect"),
    PHOENIX(12, "phoenix", "Phoenix HBase数据库", "cn.astana.sharding.extension.plugins.pagination.dialects.PhoenixDialect"),
    KINGBASE(13, "kingbase", "人大金仓", "com.ctrip.corp.obt.shard.sql.mybatis.interceptor.dialect.KingBaseDialect"),
    DM(13, "dm", "达梦", "com.ctrip.corp.obt.shard.sql.mybatis.interceptor.dialect.DmDialect"),
    OTHER(14, "other", "其他数据库", "cn.astana.sharding.extension.plugins.pagination.dialects.UnknownDialect");

    private Integer value;
    private final String db;
    private final String desc;
    private final String dialect;

    public static DbType getDbType(String dbType) {
        DbType[] dbTypes = values();
        for (DbType type : dbTypes) {
            if (type.db.equalsIgnoreCase(dbType)) {
                return type;
            }
        }
        return OTHER;
    }

    public static DbType getDbType(Integer value) {
        DbType[] dbTypes = values();
        for (DbType type : dbTypes) {
            if (type.value.equals(value)) {
                return type;
            }
        }
        return OTHER;
    }

    public Integer getValue() {
        return value;
    }

    public String getDb() {
        return this.db;
    }

    public String getDesc() {
        return this.desc;
    }

    public String getDialect(){
        return this.dialect;
    }

    private DbType(final Integer value, final String db, final String desc, final String dialect) {
        this.value = value;
        this.db = db;
        this.desc = desc;
        this.dialect = dialect;
    }
}
